<template>
  <div>
       <el-form :model="addGoodsParamsForm" ref="addGoodsParamsForm" label-position='top'>
  <el-form-item
    :label='item.attr_name'
    prop="goods_name"
    v-for="item in manyTable" :key="item.attr_id"
  >
 <el-checkbox-group v-model="item.attr_vals">
    <el-checkbox :label="itemChild" v-for='itemChild in item.attr_vals' :key="itemChild.attr_id" border></el-checkbox>
  </el-checkbox-group>
  </el-form-item>
   
   
</el-form>
  </div>
</template>

<script>
import {getCategoryParmasByAxios} from 'network/axios'
export default {
        name:'GoodsParamsForm',
        data(){
            return {
                addGoodsParamsForm:{
                  
                },
                cateId:0,
                manyTable:[],
                manyAttr:[]
            }
        },
        created(){
            this.$bus.$on('sendCategoryId',(cateId)=>{
                        this.cateId=cateId
                        console.log(this.cateId);
                         getCategoryParmasByAxios({
                id:this.cateId,
                sel:'many'
            }).then(res=>{
                const {data}=res.data
                data.forEach(element=>{
                    element.attr_vals= element.attr_vals.split(' ')
                })
                this.manyTable=data
            })
            })

           
        },
          methods:{
          getParamsForm(){
            this.manyTable.forEach(element=>{
               const obj={attr_id:0,attr_vals:''}
                    obj.attr_id=element.attr_id
                    obj.attr_vals=element.attr_vals.join(" ")
                    console.log(obj.attr_vals);
                    this.manyAttr.push(obj)
            })
    

          }
        }
}
</script>

<style>

</style>